<?php
/* $Id: my_open.issues.php,v 1.4 2003/10/08 07:19:34 tuxmonkey Exp $ */
/** 
 * @package Issue-Tracker
 * @subpackage Issues
 */

if (strpos($_SERVER['PHP_SELF'],basename(__FILE__)) !== false) {
  print "Direct module access forbidden.".basename(__FILE__);
  exit;
}


if($_GET['showall'] != "true"){
  $links[] = array(
    "img" => $_ENV['imgs']['show_closed'],
    "txt" => $lg->mm_show_closed,
    "url" => "?module=issues&action=mopen&showall=true&gid=".$_GET['gid']
  );
} else {
  $links[] = array(
    "img" => $_ENV['imgs']['hide_closed'],
    "txt" => $lg->mm_hide_closed,
    "url" => "?module=issues&action=mopen&showall=false&gid=".$_GET['gid']
  );
}

// fetch needed statuses
list($registered) = fetch_status(TYPE_REGISTERED);
$closed = implode(",",fetch_status(array(TYPE_CLOSED,TYPE_AUTO_CLOSED)));

// Make sure we have something to sort by
	$sql  = "SELECT issueid,gid AS gname,objet,status AS statu ";
	$sql .= "FROM issues ";
	$sql .= "WHERE opened_by='".$_SESSION['userid']."' ";
	$sql .= $_GET['showall'] != "true" ? "AND status NOT IN ($closed) " : "";
	$sql .= "ORDER BY status ASC";
	$t_issues = $dbi->fetch_all($sql,"array");
	if(is_array($t_issues))
	{
		foreach($t_issues as $key => $s_issues)
		{
			if(show_issue($s_issues['issueid'],$s_issues['gname']))
			{
				$lkval = $s_issues['objet'];
				$action = "?module=issues&action=view&issueid=".$s_issues['issueid'];
				$action .= "&gid=".$s_issues['gname'];
				$s_issues['objet']   =  "<a href='$action'>$lkval</a> ";	
				$t_datas[] =  $s_issues ;
			}
		}
	}
	$o_grid = new Grid('GMYOPEN',null,$lg->my_opened);
	// Catalogue
	$o_grid->setFieldcat(array('issueid','gname','objet','statu'));
	$o_grid->SetFieldAttr("issueid","width",7);
	
	$o_grid->SetFieldAttr("gname","nowrap",true);
	$o_grid->SetFieldAttr("gname","SetCexit",'group_name');
	// Button 
	$o_grid->setXlsDownload($lg->my_opened);
	$o_grid->setColumnManager();
	
	// Datas
	$o_grid->setDatas($t_datas);
	$smarty->display("title_bar.tpl");
	echo $o_grid->Display();

?>